package cn.foolishbird.hamal.frame.queryParam.wrapperHandler;

import cn.foolishbird.hamal.frame.bsassert.BsAssert;
import cn.foolishbird.hamal.frame.bsassert.info.SysInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;

/**
 * 抽象类，为了把 前端 fieldName 映射给成后端的数据库字段
 *
 * @author Eric
 * @version 1.0
 * @date 2020-09-29
 */
public abstract class AbstractQueryWrapperHandler implements QueryWrapperHandler {
    @Override
    public <T> void and(QueryWrapper<T> queryWrapper, String fieldName, Object v1, Object v2) {
        BsAssert.bsAssert(null == queryWrapper, SysInfo.RUN_TIME);
        if (StringUtils.isBlank(fieldName)) {
            return;
        }
        if (null == v1) {
            return;
        }
        doAnd(queryWrapper, fieldName, v1, v2);
    }

    public abstract <T> void doAnd(QueryWrapper<T> queryWrapper, String fieldName, Object v1, Object v2);

}
